#ifndef __GETWEATHERDATA_H__
#define __GETWEATHERDATA_H__

#include <stdio.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <unistd.h>
#include <string.h>
#include <strings.h>
#include <sys/time.h>
#include <sys/select.h>
#include <stdbool.h>
#include <stdlib.h>
#include <arpa/inet.h>

// ssl库的头文件
#include <openssl/crypto.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include "cJSON.h"

typedef struct weather_node{
    char hour_str[20];
    char weather_str[20];
    char temp_str[5];
    char wind_direction_str[20];
    char wind_power_str[20];

    struct weather_node *next;
    struct weather_node *prev;
}weather_node_t;

typedef struct weather_node_manager{
    int day_num;
    struct weather_node *head;
    struct weather_node *tail;
}weather_node_manager_t;

extern char day_weather_temp[7][20];
extern char night_weather_temp[7][20];
extern char day_weather_state[7][10];
extern weather_node_manager_t *today_weather_manager;
extern weather_node_manager_t *secondday_weather_manager;
extern weather_node_manager_t *thirdday_weather_manager;
extern weather_node_manager_t *forthday_weather_manager;
extern weather_node_manager_t *fifthday_weather_manager;
extern weather_node_manager_t *sixthday_weather_manager;
extern weather_node_manager_t *seventhday_weather_manager;
extern int weather_temp_history[8];

int init_SSL(int tcp_fd, SSL **ssl, SSL_CTX **ctx);
void destroy_SSL(SSL *ssl, SSL_CTX *ctx);
//拿到某一天的24小时天气信息
void get_oneday_weather(const char *APPCode, char *request_date, weather_node_manager_t *weather_manager, int count);

weather_node_manager_t *WeatherDoubleCircleLinkedListManagerNode();
weather_node_t *WeatherDoubleCircleLinkedListNewNode(char *hour_str,
                                                        char *weather_str,
                                                        char *temp_str,
                                                        char *wind_direction_str,
                                                        char *wind_power_str);
bool WeatherDoubleCircleLinkedListInsert(weather_node_manager_t *Pmanager,char *hour_str,
                                                                            char *weather_str,
                                                                            char *temp_str,
                                                                            char *wind_direction_str,
                                                                            char *wind_power_str);
bool WeatherDoubleCircleLinkedListDelete(weather_node_manager_t *Pmanager,char *hour_str);
void WeatherDoubleCircleLinkedListPrint(weather_node_manager_t *Pmanager);
//初始化天气数据管理节点
void init_weather_data_list(void);



#endif /* end of the __GETWEATHERDATA_H__ */
